import url from '../../../config/url'
import axios from 'axios'
axios.defaults.baseURL = url.apiUrl;

const fileupload = {
  namespaced: true,
  state: {
    uploading:"uploading",
    failed:"failed",
    done:"done"
  },

  mutations: {

  },

  actions: {
    startUploadFile(ctx,params){//上传文件
      if(Array.isArray(params.file) && params.multiple){//多文件上传
        params.file.forEach(item => {
          item.status = ctx.state.uploading
        });
      }else{//单文件上传
        params.file.status = ctx.state.uploading
        setTimeout(function(){
          params.file.status = ctx.state.done
        },2000)
      }
    },
    deleteUploadedFile(ctx,params){//删除上传的文件
      return true;
    }
  },
  getters: { //get获取数据

  }
}

export default fileupload
